package com.design.mediator.traffic2;

// 中介者接口
interface FlightMediator {
    void requestLandingPermission(Flight flight);
    void notifyDeparture(Flight flight);
}

// 航班类
class Flight {
    private String flightNumber;
    private FlightMediator mediator;

    public Flight(String flightNumber, FlightMediator mediator) {
        this.flightNumber = flightNumber;
        this.mediator = mediator;
    }

    public void requestLanding() {
        mediator.requestLandingPermission(this);
    }

    public void depart() {
        mediator.notifyDeparture(this);
    }

    public String getFlightNumber() {
        return flightNumber;
    }
}
